﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.AspNetCore.Http;
using System.Security.Claims;

namespace Microsoft.AspNetCore.Authentication.Gitee;

/// <summary>
/// GiteeHandler配置
/// </summary>
public class GiteeOptions : OAuthOptions
{
    /// <summary>
    /// 初始化一个新实例
    /// </summary>
    public GiteeOptions()
    {
        CallbackPath = new PathString("/signin-microsoft");
        AuthorizationEndpoint = GiteeDefaults.AuthorizationEndpoint;
        TokenEndpoint = GiteeDefaults.TokenEndpoint;
        UserInformationEndpoint = GiteeDefaults.UserInformationEndpoint;
        UsePkce = true;
        Scope.Add("user_info");
        Scope.Add("projects");
        Scope.Add("pull_requests");
        Scope.Add("issues");
        Scope.Add("notes");
        Scope.Add("keys");
        Scope.Add("hook");
        Scope.Add("groups");
        Scope.Add("gists");
        Scope.Add("enterprises");

        ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
        ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
        ClaimActions.MapJsonKey(ClaimTypes.Email, "email");
    }
}
